package rmi.bank;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;

import std.bank.Account;
import std.bank.Bank;

public class BankAccountClient
{
	public BankAccountClient(String host) throws MalformedURLException,
			RemoteException, NotBoundException
	{
		if (System.getSecurityManager() == null)
			System.setSecurityManager(new SecurityManager());

		Bank bank = (Bank) Naming.lookup("//" + host + "/BankAccountServer");

		Account bjarke = bank.getAccount("Bjarke");
		Account allan = bank.getAccount("Allan");
		Account milo = bank.getAccount("Milo");

		System.out.println(bjarke.getName());
		System.out.println(milo.getName());
		System.out.println(allan.getName());

		bjarke.deposit(1000);
		allan.deposit(10110);
		milo.withdraw(1337);

		System.out.println(bjarke.getName() + bjarke.getBalance());
		System.out.println(allan.getName() + allan.getBalance());
		System.out.println(milo.getName() + milo.getBalance());
	}
}
